import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { SoftwareInfo, SoftwareService } from './software.service';

@Injectable({
	providedIn: 'root',
})
export class DetailsService implements Resolve<SoftwareInfo> {
	constructor(private softManager: SoftwareService) {}
	async resolve(route: ActivatedRouteSnapshot) {
		const id = Number(route.queryParamMap.get('id'));
		const areaId = Number(route.queryParamMap.get('area_id')); 
		const software = await this.softManager.getWithAreaId(id, areaId);
		return software;
	}
}
